﻿using MediatR;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Infrastructure.Interfaces;
using Traceability_Management.Read.Api.Application.Command.Processiings_OneWay;

namespace Traceability_Management.Read.Api.Application.CommandHandler.Processiings_OneWay
{
    public class UpdateOneWayCommandHandler : IRequestHandler<UpdateOneWayCommand, ApiResult<int>>
    {
        IBaseReponsitory<Processiings_One> Processiings_One;

        public UpdateOneWayCommandHandler(IBaseReponsitory<Processiings_One> Processiings_One)
        {
            this.Processiings_One = Processiings_One;
        }

        public async Task<ApiResult<int>> Handle(UpdateOneWayCommand request, CancellationToken cancellationToken)
        {
            await Processiings_One.UpdateAsync(request.Processiings_One);
            return new ApiResult<int>
            {
                Code = ApiEnum.Success,
                Message = "保存成功",
                Data = 1
            };
        }
    }
}
